from flask import jsonify
from datetime import datetime, timezone, timedelta


def response(success=True, data=None, message=None, status=0):
    result = {
        'code': status,
        'success': success,
        'data': data,
        'message': message
    }
    return jsonify(result), 200

def time_now():
    CST = timezone(timedelta(hours=8), 'Asia/Shanghai')
    return datetime.now(CST)

def expiration_str(expires_delta):
    expiration_time = time_now() + expires_delta
    expiration_str = expiration_time.strftime('%Y/%m/%d %H:%M:%S')
    return expiration_str

# 延迟函数
def delay(seconds):
    import time
    time.sleep(seconds)